﻿using UnityEngine;
using System.Collections;

public class ChangeCamera : MonoBehaviour {

	public Camera cameraToChange;

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}

//	void OnMouseDown()
//	{
//		changeTheCamera ();
//	}

	public void changeTheCamera(){
		Camera mainCam = Camera.main;
		if(!cameraToChange.gameObject.activeSelf)
			cameraToChange.gameObject.SetActive(true);
		
		Camera.main.CopyFrom(cameraToChange);
		Camera.main.enabled = true;
		
		GameObject[] allCameras = GameObject.FindGameObjectsWithTag("Camera");
		for(int i = 0; i < allCameras.Length; i++)
			allCameras[i].camera.enabled = false;
		
		mainCam.transform.DetachChildren();
		GameObject hiddenWall = GameObject.Find("HiddenWall");
		hiddenWall.transform.parent = cameraToChange.transform;
		hiddenWall.transform.localPosition = Vector3.zero;
	}
}
